package com.example.Wisdompark.controller;

import com.example.Wisdompark.pojo.Transport_Order;
import com.example.Wisdompark.service.TransportOrderService;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 运营人员数据controller
 */
@Controller
public class TransportOrderController {

    @Autowired
    private TransportOrderService transportOrderService;

    // 地图展示
    @RequestMapping("/baiduMap")
    public String baiduMap(){
        // 跳转到地图页面
        return "operations/baiduMapDemo";
    }

    // 相应地图的Ajax请求,返回正在运输订单的车辆的信息
    @RequestMapping("/showWorkCar")
    public void QueryOrder(
           HttpServletResponse response
    ) {
        List<Transport_Order> transport_orders = transportOrderService.queryOrderByOrderNum();
        Gson gson = new Gson();
        String  s = gson.toJson(transport_orders);

        try {
            response.getWriter().write(s);
        } catch (IOException e) {
           e.printStackTrace();
        }
    }
}
